﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Authority.EFRepositoryImpl.Migrations
{
    /// <inheritdoc />
    public partial class init : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "ActionAuthority",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    Code = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    SubsystemID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    DateAddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    DateUpTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ActionAuthority", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "AuthorityModule",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    Code = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    DateAddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    DateUpTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AuthorityModule", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "AuthorityModuleCarryActionAuthority",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    AuthorityModuleID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    ActionAuthorityID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    DateAddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    DateUpTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AuthorityModuleCarryActionAuthority", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "AuthorityModuleCarryMenuAuthority",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    AuthorityModuleID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    MenuAuthorityID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    DateAddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    DateUpTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AuthorityModuleCarryMenuAuthority", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "AuthorityModuleCarryRoutingAuthority",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    AuthorityModuleID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RoutingAuthorityID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    DateAddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    DateUpTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AuthorityModuleCarryRoutingAuthority", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "MenuAuthority",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    Code = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    SubsystemID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RoutingAuthorityID = table.Column<Guid>(type: "uniqueidentifier", maxLength: 100, nullable: true),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    DateAddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    DateUpTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    ParentID = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MenuAuthority", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "RoleAffectedByAuthorityModule",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    AuthorityModuleID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RoleAuthorityID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    DateAddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    DateUpTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RoleAffectedByAuthorityModule", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "RoleAuthority",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    Code = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    DateAddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    DateUpTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    ParentID = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RoleAuthority", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "RoleAuthorityAction",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RoleAuthorityID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    ActionAuthorityID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    DateAddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    DateUpTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RoleAuthorityAction", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "RoleAuthorityMenu",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RoleAuthorityID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    MenuAuthorityID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    DateAddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    DateUpTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RoleAuthorityMenu", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "RoleAuthorityRouting",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RoleAuthorityID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RoutingAuthorityID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    DateAddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    DateUpTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RoleAuthorityRouting", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "RoutingAuthority",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    Code = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    Address = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
                    SubsystemID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    DateAddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    DateUpTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    ParentID = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RoutingAuthority", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "RoutingCarryAction",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RoutingAuthorityID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    ActionAuthorityID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    DateAddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    DateUpTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RoutingCarryAction", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Subsystem",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    Code = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    SystemIconID = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    DateAddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    DateUpTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Subsystem", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "User",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    AccountNumber = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    Password = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    WeCathOpenID = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    DateAddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    DateUpTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_User", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "UserRoleAuthority",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    UserID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RoleAuthorityID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    IsDelete = table.Column<bool>(type: "bit", nullable: false),
                    DateAddTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    DateUpTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserRoleAuthority", x => x.ID);
                });
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "ActionAuthority");

            migrationBuilder.DropTable(
                name: "AuthorityModule");

            migrationBuilder.DropTable(
                name: "AuthorityModuleCarryActionAuthority");

            migrationBuilder.DropTable(
                name: "AuthorityModuleCarryMenuAuthority");

            migrationBuilder.DropTable(
                name: "AuthorityModuleCarryRoutingAuthority");

            migrationBuilder.DropTable(
                name: "MenuAuthority");

            migrationBuilder.DropTable(
                name: "RoleAffectedByAuthorityModule");

            migrationBuilder.DropTable(
                name: "RoleAuthority");

            migrationBuilder.DropTable(
                name: "RoleAuthorityAction");

            migrationBuilder.DropTable(
                name: "RoleAuthorityMenu");

            migrationBuilder.DropTable(
                name: "RoleAuthorityRouting");

            migrationBuilder.DropTable(
                name: "RoutingAuthority");

            migrationBuilder.DropTable(
                name: "RoutingCarryAction");

            migrationBuilder.DropTable(
                name: "Subsystem");

            migrationBuilder.DropTable(
                name: "User");

            migrationBuilder.DropTable(
                name: "UserRoleAuthority");
        }
    }
}
